/**
 * 初始化银行收支日结报表详情对话框
 */
var ExpenditureInfoDlg = {
    expenditureInfoData : {}
};

/**
 * 清除数据
 */
ExpenditureInfoDlg.clearData = function() {
    this.expenditureInfoData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
ExpenditureInfoDlg.set = function(key, val) {
    this.expenditureInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
ExpenditureInfoDlg.get = function(key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
ExpenditureInfoDlg.close = function() {
    parent.layer.close(window.parent.Expenditure.layerIndex);
}

/**
 * 收集数据
 */
ExpenditureInfoDlg.collectData = function() {
    this
    .set('id')
    .set('platform')
    .set('recharge')
    .set('otherDeposits')
    .set('reflect')
    .set('otherWithdrawals')
    .set('fee')
    .set('revdate')
    .set('creattime')
    .set('updatetime');
}

/**
 * 提交添加
 */
ExpenditureInfoDlg.addSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/expenditure/add", function(data){
        Feng.success("添加成功!");
        window.parent.Expenditure.table.refresh();
        ExpenditureInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
	if(this.expenditureInfoData.revdate==''){
		Feng.error("报表日期不能为空!");
	return ;
	}
	ajax.set(this.expenditureInfoData);
    ajax.start();
}

/**
 * 提交修改
 */
ExpenditureInfoDlg.editSubmit = function() {

    this.clearData();
    this.collectData();

    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/expenditure/update", function(data){
        Feng.success("修改成功!");
        window.parent.Expenditure.table.refresh();
        ExpenditureInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.expenditureInfoData);
    ajax.start();
}


/**
 * 导出
 */
ExpenditureInfoDlg.Export = function(){ 
		    var revdate = $("#revdate").val();
			if(revdate=='' || revdate==undefined    ){
				layer.open({
				  content: '请选择日期导出!'
				});
				return;
			}
	 window.location="/expenditure/exportExpenditure?revdate="+revdate;		
			
			
}

$(function() {

});
